package cn.evun.tms.generator.task;

import cn.evun.tms.generator.framework.AbstractApplicationTask;
import cn.evun.tms.generator.framework.context.ApplicationContext;
import cn.evun.tms.generator.handler.BaseHandler;
import cn.evun.tms.generator.handler.impl.ServiceTestHandler;
import cn.evun.tms.generator.model.ServiceTestInfo;

import java.util.List;

public class ServiceTestTask extends AbstractApplicationTask {

	private static String SERVICETEST_FTL = "template/ServiceTest.ftl";

	@SuppressWarnings("unchecked")
	@Override
	protected boolean doInternal(ApplicationContext context) throws Exception {
		logger.info("开始生成service单元测试类。。。");

		List<ServiceTestInfo> list = (List<ServiceTestInfo>) context.getAttribute("serviceTestInfos");

		BaseHandler<ServiceTestInfo> baseHandler = null;
		for (ServiceTestInfo serviceTestInfo : list) {
			baseHandler = new ServiceTestHandler(SERVICETEST_FTL, serviceTestInfo);
			baseHandler.execute(context);
		}

		logger.info("生成service单元测试类完成。。。");
		return false;
	}

}
